{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('gunweizhi', array('op' => 'post'))}">{if $id==0}添加滚动文字{else}修改滚动文字{/if}</a></li>
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('gunweizhi', array('op' => 'display'))}">管理滚动文字</a></li>
</ul>
{if $operation == 'post'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" id="form1">
        <div class="panel panel-default">
            <div class="panel-heading">滚动文字详细设置</div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">流动文字内容</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" name="catename" class="form-control" value="{$gunweizhi['name']}" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">滚动文字外链名片ID</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" name="url" class="form-control" value="{$gunweizhi['url']}" />
                    </div>
                </div>
                <div class="form-group">

			<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">起止时间</label>

			<div class="col-sm-8 col-lg-9 col-xs-12">

				{php echo tpl_form_field_daterange('activity',array('start'=>date('Y-m-d H:i:s',empty($gunweizhi['start_time'])?time():$gunweizhi['start_time']),'end'=>date('Y-m-d H:i:s',empty($gunweizhi['end_time'])?time()+3600*5:$gunweizhi['end_time'])),true);}

				<span class="help-block">起止时间</strong></span>

			</div>

		</div>
            </div>
        </div>
        
        <div class="form-group">
            <div class="col-sm-12">
                <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
</script>
{elseif $operation == 'display'}
<div class="main">
	<div class="slide">
		<form action="" method="post" onsubmit="return formcheck(this)">
            <div class="panel panel-default">
                <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            
                            <th style="width:5px;">ID</th>
                            <th style="width:15px;">文字内容</th>
                            <th style="width:15px;">名片ID</th>
                            <th style="width:15px;">开始时间</th>
                            <th style="width:15px;">结束时间</th>
                            <th style="width:20px;" class="text-center">审核-编辑-删除</th>
                        </tr>
                    </thead>
                    <tbody>
                    {loop $gunweizhi $row}
                        <tr>
                            
                            <td>
                                {$row['id']}
                            </td>
                            <td>
                                {$row['name']}
                            </td>
                            <td>
                                 {$row['url']}
                            </td>
                            <td>{php echo date('Y-m-d H:i:s',$row['start_time'])}</td>
                            <td>{php echo date('Y-m-d H:i:s',$row['end_time'])}</td>
                         
                            <td class="text-center">
                                
                     <a id="id{$item['id']}" href="javascript:shen('{php echo $this->createWebUrl('gunweizhi', array('op' => 'shenhe', 'id' =>$row['id'],'key'=>$row['key']))}',{$row['id']});" title="{if $row['key']==1}不通过{else}通过{/if}" class="shen btn btn-sm {if $row['key']==0}btn-danger{else}btn-success{/if}"><i class="fa fa-check"></i></a>

					<a href="{php echo $this->createWebUrl('gunweizhi', array('op' => 'post', 'id' => $row['id']))}" title="编辑" class="btn btn-primary btn-sm"><span class="fa fa-edit"></span></a>

					<a onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWebUrl('gunweizhi', array('op' => 'delete','id' => $row['id']))}" title="删除" class="btn btn-sm btn-danger"><span class="fa fa-times" ></span></a>

                            </td>
                        </tr>
                    {/loop}
                        <tr>
                            <td></td>
                            <td colspan="4">
                                <a href="{php echo $this->createWebUrl('gunweizhi', array('op' => 'post'))}"><i class="fa fa-plus"></i> 添加新滚动文字</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
                </div>
            </div>
        </form>
	</div>
</div>

<script>
function shen(url,id){

						$.getJSON(url,function(data){

						if(data.a==0){

						$("#id"+id).removeClass('btn-success');

						$("#id"+id).addClass('btn-danger');

						}else if(data.a==1){

						$("#id"+id).removeClass('btn-danger');

						$("#id"+id).addClass('btn-success');

						}

						location.reload();

						})

}

$('#form2').submit(function(){

if($(":checkbox[name='delete[]']:checked").size() > 0){

return confirm('删除后不可恢复，您确定删除吗？');

}

return false;

}); 
</script>	
{/if}
{template 'common/footer'}